package com.rabbiter.cm.domain;

import com.fasterxml.jackson.annotation.JsonFormat;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.io.Serializable;
import java.time.LocalDate;
import java.util.Objects;

/**
 * 场次实体类，用于表示电影院的电影放映场次信息。
 * 包含场次的基本信息、时间安排、票价、座位状态以及关联的影厅和电影信息。
 */
public class SysSession implements Serializable {

    /**
     * 序列化版本唯一标识符，确保类的版本一致性。
     */
    private static final Long serialVersionUID = 1L;

    /**
     * 场次的唯一标识 ID。
     */
    private Long sessionId;

    /**
     * 影厅编号，不能为空。
     * 表示该场次所属的影厅。
     */
    @NotNull(message = "场次所在影厅不能为空")
    private Long hallId;

    /**
     * 电影语言版本，不能为空。
     * 如“国语”、“英语原声”等。
     */
    @NotBlank(message = "场次电影语言版本不能为空")
    private String languageVersion;

    /**
     * 电影编号，不能为空。
     * 表示当前场次播放的电影。
     */
    @NotNull(message = "场次安排电影不能为空")
    private Long movieId;

    /**
     * 放映开始时间，格式为 HH:mm。
     */
    @JsonFormat(locale = "zh", timezone = "GMT+8", pattern = "HH:mm")
    private String playTime;

    /**
     * 放映结束时间，格式为 HH:mm。
     */
    @JsonFormat(locale = "zh", timezone = "GMT+8", pattern = "HH:mm")
    private String endTime;

    /**
     * 截止时间，此时间之前不可删除或修改电影、影厅信息。
     * 格式为 HH:mm。
     */
    private String deadline;

    /**
     * 场次日期，不能为空，格式为 yyyy-MM-dd。
     */
    @NotNull(message = "场次日期不能为空")
    @JsonFormat(locale = "zh", timezone = "GMT+8", pattern = "yyyy-MM-dd")
    private LocalDate sessionDate;

    /**
     * 场次票价，不能为空且不能为负数。
     */
    @NotNull(message = "场次票价不能为空")
    @Size(min = 0, message = "场次票价不能为负数")
    private Double sessionPrice;

    /**
     * 场次提示信息，可为空。
     */
    private String sessionTips;

    /**
     * 场次座位信息字符串，不能为空。
     * 通常以特定格式表示座位分布和状态（如 JSON 字符串）。
     */
    @NotBlank(message = "场次座位信息不能为空")
    private String sessionSeats;

    /**
     * 总座位数量。
     */
    private Integer seatNums;

    /**
     * 已售出的座位数量。
     */
    private Integer sallNums;

    /**
     * 关联的影厅对象，用于获取影厅详细信息。
     */
    private SysHall sysHall;

    /**
     * 关联的电影对象，用于获取电影详细信息。
     */
    private SysMovie sysMovie;


    /**
     * 默认构造函数，用于创建一个空的场次对象。
     */
    public SysSession() {
    }

    /**
     * 带参数的构造函数，用于初始化所有字段。
     *
     * @param sessionId       场次 ID
     * @param hallId          影厅 ID
     * @param languageVersion 语言版本
     * @param movieId         电影 ID
     * @param playTime        开始时间
     * @param endTime         结束时间
     * @param deadline        截止时间
     * @param sessionDate     场次日期
     * @param sessionPrice    票价
     * @param sessionTips     提示信息
     * @param sessionSeats    座位信息
     * @param seatNums        总座位数
     * @param sallNums        已售座位数
     * @param sysHall         关联的影厅对象
     * @param sysMovie        关联的电影对象
     */
    public SysSession(Long sessionId, Long hallId, String languageVersion, Long movieId,
                      String playTime, String endTime, String deadline, LocalDate sessionDate,
                      Double sessionPrice, String sessionTips, String sessionSeats,
                      Integer seatNums, Integer sallNums, SysHall sysHall, SysMovie sysMovie) {
        this.sessionId = sessionId;
        this.hallId = hallId;
        this.languageVersion = languageVersion;
        this.movieId = movieId;
        this.playTime = playTime;
        this.endTime = endTime;
        this.deadline = deadline;
        this.sessionDate = sessionDate;
        this.sessionPrice = sessionPrice;
        this.sessionTips = sessionTips;
        this.sessionSeats = sessionSeats;
        this.seatNums = seatNums;
        this.sallNums = sallNums;
        this.sysHall = sysHall;
        this.sysMovie = sysMovie;
    }

    // Getter 和 Setter 方法

    public Long getSessionId() {
        return sessionId;
    }

    public void setSessionId(Long sessionId) {
        this.sessionId = sessionId;
    }

    public Long getHallId() {
        return hallId;
    }

    public void setHallId(Long hallId) {
        this.hallId = hallId;
    }

    public String getLanguageVersion() {
        return languageVersion;
    }

    public void setLanguageVersion(String languageVersion) {
        this.languageVersion = languageVersion;
    }

    public Long getMovieId() {
        return movieId;
    }

    public void setMovieId(Long movieId) {
        this.movieId = movieId;
    }

    public String getPlayTime() {
        return playTime;
    }

    public void setPlayTime(String playTime) {
        this.playTime = playTime;
    }

    public String getEndTime() {
        return endTime;
    }

    public void setEndTime(String endTime) {
        this.endTime = endTime;
    }

    public String getDeadline() {
        return deadline;
    }

    public void setDeadline(String deadline) {
        this.deadline = deadline;
    }

    public LocalDate getSessionDate() {
        return sessionDate;
    }

    public void setSessionDate(LocalDate sessionDate) {
        this.sessionDate = sessionDate;
    }

    public Double getSessionPrice() {
        return sessionPrice;
    }

    public void setSessionPrice(Double sessionPrice) {
        this.sessionPrice = sessionPrice;
    }

    public String getSessionTips() {
        return sessionTips;
    }

    public void setSessionTips(String sessionTips) {
        this.sessionTips = sessionTips;
    }

    public String getSessionSeats() {
        return sessionSeats;
    }

    public void setSessionSeats(String sessionSeats) {
        this.sessionSeats = sessionSeats;
    }

    public Integer getSeatNums() {
        return seatNums;
    }

    public void setSeatNums(Integer seatNums) {
        this.seatNums = seatNums;
    }

    public Integer getSallNums() {
        return sallNums;
    }

    public void setSallNums(Integer sallNums) {
        this.sallNums = sallNums;
    }

    public SysHall getSysHall() {
        return sysHall;
    }

    public void setSysHall(SysHall sysHall) {
        this.sysHall = sysHall;
    }

    public SysMovie getSysMovie() {
        return sysMovie;
    }

    public void setSysMovie(SysMovie sysMovie) {
        this.sysMovie = sysMovie;
    }

    /**
     * 判断当前对象是否与另一个对象相等。
     * 根据所有字段判断两个场次对象是否相同。
     *
     * @param o 要比较的对象
     * @return 如果对象相等则返回 true，否则返回 false
     */
    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        SysSession that = (SysSession) o;
        return Objects.equals(sessionId, that.sessionId) &&
               Objects.equals(hallId, that.hallId) &&
               Objects.equals(languageVersion, that.languageVersion) &&
               Objects.equals(movieId, that.movieId) &&
               Objects.equals(playTime, that.playTime) &&
               Objects.equals(endTime, that.endTime) &&
               Objects.equals(deadline, that.deadline) &&
               Objects.equals(sessionDate, that.sessionDate) &&
               Objects.equals(sessionPrice, that.sessionPrice) &&
               Objects.equals(sessionTips, that.sessionTips) &&
               Objects.equals(sessionSeats, that.sessionSeats) &&
               Objects.equals(seatNums, that.seatNums) &&
               Objects.equals(sallNums, that.sallNums) &&
               Objects.equals(sysHall, that.sysHall) &&
               Objects.equals(sysMovie, that.sysMovie);
    }

    /**
     * 生成基于所有字段的哈希码。
     *
     * @return 返回哈希码值
     */
    @Override
    public int hashCode() {
        return Objects.hash(sessionId, hallId, languageVersion, movieId, playTime, endTime,
                deadline, sessionDate, sessionPrice, sessionTips, sessionSeats,
                seatNums, sallNums, sysHall, sysMovie);
    }

    /**
     * 返回当前对象的字符串表示，用于调试和日志输出。
     *
     * @return 包含所有字段信息的字符串
     */
    @Override
    public String toString() {
        return "SysSession{" +
                "sessionId=" + sessionId +
                ", hallId=" + hallId +
                ", languageVersion='" + languageVersion + '\'' +
                ", movieId=" + movieId +
                ", playTime='" + playTime + '\'' +
                ", endTime='" + endTime + '\'' +
                ", deadline='" + deadline + '\'' +
                ", sessionDate=" + sessionDate +
                ", sessionPrice=" + sessionPrice +
                ", sessionTips='" + sessionTips + '\'' +
                ", sessionSeats='" + sessionSeats + '\'' +
                ", seatNums=" + seatNums +
                ", sallNums=" + sallNums +
                ", sysHall=" + sysHall +
                ", sysMovie=" + sysMovie +
                '}';
    }
}
package com.rabbiter.cm.domain;

import com.fasterxml.jackson.annotation.JsonFormat;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.io.Serializable;
import java.time.LocalDate;
import java.util.Objects;

/**
 * 场次实体类
 */
public class SysSession implements Serializable {

    private static final Long serialVersionUID = 1L;

    //场次编号
    private Long sessionId;

    //影厅编号
    @NotNull(message = "场次所在影厅不能为空")
    private Long hallId;

    //该场次语言版本
    @NotBlank(message = "场次电影语言版本不能为空")
    private String languageVersion;

    // 电影编号
    @NotNull(message = "场次安排电影不能为空")
    private Long movieId;

    @JsonFormat(locale = "zh", timezone = "GMT+8", pattern = "HH:mm")
    private String playTime;

    @JsonFormat(locale = "zh", timezone = "GMT+8", pattern = "HH:mm")
    private String endTime;

    // 截止时间，此时间之前不可删不可改电影、影厅信息
    private String deadline;

    // 场次日期
    @NotNull(message = "场次日期不能为空")
    @JsonFormat(locale = "zh", timezone = "GMT+8", pattern = "yyyy-MM-dd")
    private LocalDate sessionDate;

    // 场次票价
    @NotNull(message = "场次票价不能为空")
    @Size(min = 0, message = "场次票价不能为负数")
    private Double sessionPrice;

    // 场次提示
    private String sessionTips;

    // 场次座位信息
    @NotBlank(message = "场次座位信息不能为空")
    private String sessionSeats;

    private Integer seatNums;

    // 已售座位数
    private Integer sallNums;

    private SysHall sysHall;

    private SysMovie sysMovie;

    public SysSession() {
    }

    public SysSession(Long sessionId, Long hallId, String languageVersion, Long movieId, String playTime, String endTime, String deadline, LocalDate sessionDate, Double sessionPrice, String sessionTips, String sessionSeats, Integer seatNums, Integer sallNums, SysHall sysHall, SysMovie sysMovie) {
        this.sessionId = sessionId;
        this.hallId = hallId;
        this.languageVersion = languageVersion;
        this.movieId = movieId;
        this.playTime = playTime;
        this.endTime = endTime;
        this.deadline = deadline;
        this.sessionDate = sessionDate;
        this.sessionPrice = sessionPrice;
        this.sessionTips = sessionTips;
        this.sessionSeats = sessionSeats;
        this.seatNums = seatNums;
        this.sallNums = sallNums;
        this.sysHall = sysHall;
        this.sysMovie = sysMovie;
    }

    public Long getSessionId() {
        return sessionId;
    }

    public void setSessionId(Long sessionId) {
        this.sessionId = sessionId;
    }

    public Long getHallId() {
        return hallId;
    }

    public void setHallId(Long hallId) {
        this.hallId = hallId;
    }

    public String getLanguageVersion() {
        return languageVersion;
    }

    public void setLanguageVersion(String languageVersion) {
        this.languageVersion = languageVersion;
    }

    public Long getMovieId() {
        return movieId;
    }

    public void setMovieId(Long movieId) {
        this.movieId = movieId;
    }

    public String getPlayTime() {
        return playTime;
    }

    public void setPlayTime(String playTime) {
        this.playTime = playTime;
    }

    public String getEndTime() {
        return endTime;
    }

    public void setEndTime(String endTime) {
        this.endTime = endTime;
    }

    public String getDeadline() {
        return deadline;
    }

    public void setDeadline(String deadline) {
        this.deadline = deadline;
    }

    public LocalDate getSessionDate() {
        return sessionDate;
    }

    public void setSessionDate(LocalDate sessionDate) {
        this.sessionDate = sessionDate;
    }

    public Double getSessionPrice() {
        return sessionPrice;
    }

    public void setSessionPrice(Double sessionPrice) {
        this.sessionPrice = sessionPrice;
    }

    public String getSessionTips() {
        return sessionTips;
    }

    public void setSessionTips(String sessionTips) {
        this.sessionTips = sessionTips;
    }

    public String getSessionSeats() {
        return sessionSeats;
    }

    public void setSessionSeats(String sessionSeats) {
        this.sessionSeats = sessionSeats;
    }

    public Integer getSeatNums() {
        return seatNums;
    }

    public void setSeatNums(Integer seatNums) {
        this.seatNums = seatNums;
    }

    public Integer getSallNums() {
        return sallNums;
    }

    public void setSallNums(Integer sallNums) {
        this.sallNums = sallNums;
    }

    public SysHall getSysHall() {
        return sysHall;
    }

    public void setSysHall(SysHall sysHall) {
        this.sysHall = sysHall;
    }

    public SysMovie getSysMovie() {
        return sysMovie;
    }

    public void setSysMovie(SysMovie sysMovie) {
        this.sysMovie = sysMovie;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        SysSession that = (SysSession) o;
        return Objects.equals(sessionId, that.sessionId) && Objects.equals(hallId, that.hallId) && Objects.equals(languageVersion, that.languageVersion) && Objects.equals(movieId, that.movieId) && Objects.equals(playTime, that.playTime) && Objects.equals(endTime, that.endTime) && Objects.equals(deadline, that.deadline) && Objects.equals(sessionDate, that.sessionDate) && Objects.equals(sessionPrice, that.sessionPrice) && Objects.equals(sessionTips, that.sessionTips) && Objects.equals(sessionSeats, that.sessionSeats) && Objects.equals(seatNums, that.seatNums) && Objects.equals(sallNums, that.sallNums) && Objects.equals(sysHall, that.sysHall) && Objects.equals(sysMovie, that.sysMovie);
    }

    @Override
    public int hashCode() {
        return Objects.hash(sessionId, hallId, languageVersion, movieId, playTime, endTime, deadline, sessionDate, sessionPrice, sessionTips, sessionSeats, seatNums, sallNums, sysHall, sysMovie);
    }

    @Override
    public String toString() {
        return "SysSession{" +
                "sessionId=" + sessionId +
                ", hallId=" + hallId +
                ", languageVersion='" + languageVersion + '\'' +
                ", movieId=" + movieId +
                ", playTime='" + playTime + '\'' +
                ", endTime='" + endTime + '\'' +
                ", deadline='" + deadline + '\'' +
                ", sessionDate=" + sessionDate +
                ", sessionPrice=" + sessionPrice +
                ", sessionTips='" + sessionTips + '\'' +
                ", sessionSeats='" + sessionSeats + '\'' +
                ", seatNums=" + seatNums +
                ", sallNums=" + sallNums +
                ", sysHall=" + sysHall +
                ", sysMovie=" + sysMovie +
                '}';
    }
}
